<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="<?= base_url(1); ?>" />
<link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
<script src="js/time.js?"></script>
<script type="text/javascript">         	
            function addp()
            {
            	var i = document.getElementsByName("childP").length;
                
                str = '<table id ="p'+i+'" width="100%" name="childP">'+   
                	'<tr><td>&nbsp;</td><td>&nbsp;</td></tr>'+             
	              '<tr>'+
	                '<td><div align="center">'+
	                    '<?= translate("ACTIVITY_ACTIVITYEDIT_NAME") ?>'+
	                  '</div></td>'+
	                '<td >'+
	                  '<input type="text" name="row[giftbag_name][]" id="giftbag_name'+i+'" >'+
	                '</td>'+
	              '</tr>'+
					'<tr>'+
		                '<td><div align="center">'+
	                    '<?= translate("ACTIVITY_ACTIVITYEDIT_OBJECT") ?>'+
	                  '</div></td>'+
	                  '<td >'+
		                    '<input type="text" size="39" placeholder="<?= translate("PLASE_INPUT_ITEM") ?>" '+ 
	                          	' name="row[giftbag_id][]" id="giftbag_id'+i+'"class="autocomplete" table="type_object" />'+
		              '</td>'+
	              	'</tr>'+
	              	'<tr >'+
	                '<td><div align="center"><?= translate("ACTIVITY_ACTIVITYEDIT_VIP") ?></div></td>'+
	                '<td >'+
	                	'<select name="row[viplevel][]" id="viplevel'+i+'">'+                     
	                    '<option value="1" >1</option>'+
	                    '<option value="2" >2</option>'+
	                    '<option value="3" >3</option>'+
	                    '<option value="4" >4</option>'+
	                    '<option value="5" >5</option>'+
	                    '<option value="6" >6</option>'+
	                    '<option value="7" >7</option>'+
	                    '<option value="8" >8</option>'+
	                    '<option value="9" >9</option>'+
	                    '<option value="10" >10</option>'+
	                  '</select>'+
	               '</td>'+
	              '</tr>'+
	              '</table>';
                	
                $("#add").append(str);
                autocomplete();
                $("#giftbag_id"+i).formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#giftbag_name"+i).formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
            }
            function removep()
            {
            	var i = document.getElementsByName("childP").length-1;
                
                if (i > 0)
                {
                    //alert(i);
                    $("#p" + i).remove();
                }
            }

        </script>
</head>
<body>
<?php include(VIEWPATH . 'common/main_header.php'); ?>
<?php //var_dump($row);?>
<div align="center">
  <th><?= translate('ACTIVITY_ACTIVITYEDIT_VIPGIFT') ?></th>
</div>
<form action="" method="POST" id="rowForm">
  <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
    <!-- vip充值 -->
    <!--  
            	<tr>
            	  <td colspan="2"><div align="center"><?= translate('ACTIVITY_ACTIVITYEDIT_VIPGIFT') ?></div></td>
            	</tr>
				-->
      <?php for( $i = 0; $i < count($row); ++$i) {?>
    <table id ="p<?=$i ?>" width="100%" name="childP">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ACTIVITYEDIT_NAME') ?>
          </div></td>
        <td >
            <input type="text" name="row[giftbag_name][]" id="giftbag_name<?=$i ?>" value="<?= $row[$i]['giftbag_name'] ?>">
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ACTIVITYEDIT_OBJECT') ?>
          </div></td>
        <td >
            <input type="text" size="39" placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" 
                            	name="row[giftbag_id][]" id="giftbag_id<?=$i ?>" value = '<?=$row[$i]['giftbag_id'] ?>' 
	                            	class="autocomplete" table="type_object" />
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ACTIVITYEDIT_VIP') ?>
          </div></td>
        <td>
            <select name="row[viplevel][]" id="viplevel<?=$i ?>">
              <option value="1" <?php if(1== $row[$i]['viplevel']) { echo "selected"; } ?> >1</option>
              <option value="2" <?php if(2== $row[$i]['viplevel']) { echo "selected"; } ?> >2</option>
              <option value="3" <?php if(3== $row[$i]['viplevel']) { echo "selected"; } ?> >3</option>
              <option value="4" <?php if(4== $row[$i]['viplevel']) { echo "selected"; } ?> >4</option>
              <option value="5" <?php if(5== $row[$i]['viplevel']) { echo "selected"; } ?> >5</option>
              <option value="6" <?php if(6== $row[$i]['viplevel']) { echo "selected"; } ?> >6</option>
              <option value="7" <?php if(7== $row[$i]['viplevel']) { echo "selected"; } ?> >7</option>
              <option value="8" <?php if(8== $row[$i]['viplevel']) { echo "selected"; } ?> >8</option>
              <option value="9" <?php if(9== $row[$i]['viplevel']) { echo "selected"; } ?> >9</option>
              <option value="10" <?php if(10== $row[$i]['viplevel']) { echo "selected"; } ?> >10</option>
            </select>
        </td>
      </tr>
    </table>
    <? } ?>
    <p id ="add">
    </p>
    
    <table width="100%">
      <tr>
        <td><div align="center">
            <input type="button" onClick="addp()" value="<?= translate('ADD_ONE') ?>" />
          </div></td>
        <td><div align="center">
            <input type="button" onClick="removep()" value="<?= translate('REMOVE_ONE') ?>" />
          </div></td>
      </tr>
      <tr>
        <td><div align="center">
            <input type="hidden" name="row[isEver]" value="<?= $row['isEver'] ?>">
            <input name="submit" type="submit" id="submit" value="<?= translate('SUBMIT') ?>"/>
          </div></td>
        <td><div align="center">
            <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
          </div></td>
      </tr>
    </table>
  </table>
</form>
<script type="text/javascript">
            SG.init("core.form", function() {
                $.formValidator.initConfig({formid: "#rowForm", submitonce: true});
                for(var count = 0; count < <?=count($row) ?>; ++count)
                {
                	$("#giftbag_name"+count).formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                	$("#giftbag_id"+count).formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
            	}
            });
        </script>
</body>
</html>
